package com.keyinong.jiashiyuan.view;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.keyinong.jiashiyuan.R;

public class MyFramgment extends Fragment{
	View view;
	LinearLayout ll_peisongyuan,ll_lianxi;
	TextView tv_name;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		try {
			view=View.inflate(getActivity(), R.layout.fragment_me, null);
			setupView();
			addListener();
			SharedPreferences sp = getActivity().getSharedPreferences("spReg", Context.MODE_PRIVATE);
			String name = sp.getString("name", "");
			tv_name.setText(name);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return view;
	}
	private void addListener() {
		ll_peisongyuan.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				getActivity().startActivity(new Intent(getActivity(),ZhiduActivity.class));
			}
		});
		ll_lianxi.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				getActivity().startActivity(new Intent(getActivity(),CangkuActivity.class));
				
			}
		});
		
	}
	private void setupView() {
		ll_peisongyuan=(LinearLayout)view.findViewById(R.id.ll_peisongyuan);
		ll_lianxi=(LinearLayout)view.findViewById(R.id.ll_lianxi);
		tv_name=(TextView)view.findViewById(R.id.tv_name);
	}
}
